package model;

import org.bson.types.ObjectId;

import com.google.code.morphia.dao.BasicDAO;
import com.google.code.morphia.query.Query;

import entity.Question;

public class QuestionModel extends BasicDAO<Question, ObjectId> {

	public QuestionModel() {
		super(DBConnection.getMongo(), DBConnection.getMorphia(), DBConnection
				.getDatabase());
	}

	public Question findUncheckQuestion() {
		Query<Question> q = ds.find(Question.class);
		q.field("languageStatus").equals(null);
		q.field("lang").equal("en");
		q.field("hadContent").equal(1);
		q.order("-lastUpdateDate");
		System.out.println(q.countAll());
		return q.get();
	}

	public Question findByUrl(String url) {
		Query<Question> q = ds.find(Question.class);
		q.field("url").equal(url); 
		System.out.println(q.countAll());
		return q.get();
	}

}